<?php
//--------单例模式-----
class Site{
	//属性
	public $siteName;
	//本类静态实例
	protected static $instance = null;
	//禁用掉构造器
	private function __construct($siteName){
		$this->siteName = $siteName;
	}
	//获取本类的一实例
	public static function getInstance($siteName='66666'){
		if(!self::$instance instanceof self){
			self::$instance = new self($siteName);
		}
		return self::$instance;
	}
}
//----------工厂模式，生成本类的单一实例----------------------------------
class Factory{
	//创建指定类的实例
	public static function create(){
		return Site::getInstance();
	}
}
//------------对象注册树------------
class Register{
	//创建对象池：数组
	protected static $objects = [];
	//生成对象树
	public static function set($alias,$object){
		self::$objects[$alias] = $object;
	}
	//从树上面取下对象
	public static function get($alias){
		return self::$objects[$alias];
	}
	//把树上的对象吃掉
	public static function _unset($alias){
		unset(self::$objects[$alias]);
	}
}


// Register::set('hello',Factory::create());
// $obj = Register::get('hello');
// $ob = Register::get('hello');
// var_dump($obj);
// var_dump($ob);
// echo "<hr>";
// echo $obj->siteName;

























